
// U7ObjViewerDlg.h : header file
//

#pragma once

#include "DynObj.h"
#include "Graphic.h"
#include "AnimationThread.h"
#include "U7FileDefs.h"
#include "U7FilesLoader.h"
#include "U7Objs.h"
#include "WorldMap.h"

#include "afxwin.h"
#include "afxcmn.h"

// CU7ObjViewerDlg dialog
class CU7ObjViewerDlg : public CDialogEx, public AnimationThread
{
	DECLARE_OBJ_MAP(6); // 6 is the count of dialog items

	CCriticalSection m_CritSection; // should protect m_pGraphic & data in WorldMap

	CString m_strRootPath;

	PGRAPHIC m_pGraphic;

	CPoint m_ptDisplayOrigin;
	bool m_bLButtonCaptured;
	CPoint m_ptLastCaptured;
	CPoint m_ptLastDisplayOrigin;
	bool m_bRButtonCaptured;

	CPoint m_ptNewDisplayOrigin; // to synchronize for map loading.

	BYTE m_bitmapInfo[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256];

	DWORD m_dwTime;
	U7FilesLoader m_FilesLoader;
	TimeQueue m_TQueue;
	WorldMap m_map;
	int m_viewZMax;
	bool m_bMinmapVisible;
	CRect m_rcMinimap;

	BasicObject* m_selectedObject;
	U7VECTOR3 m_selCoords;

	void LoadFiles();

	PSHAPEENTRY m_curShapeEntry;
	long m_curShapeLength;
	int m_nCurFrameIndex;
	bool m_bAnimated;

	volatile bool m_bIsPaused;

	virtual void UpdateGame();
	virtual void RenderGame();
	virtual void PaintScreen();

	void CreateMiniMap();

// Construction
public:
	CU7ObjViewerDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_U7OBJVIEWER_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnMove( int, int );					// ON_WM_MOVE()
	afx_msg void OnSize( UINT, int, int );				// ON_WM_SIZE()
	afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);	// ON_WM_GETMINMAXINFO()
	afx_msg void OnBnClickedCancel();
	afx_msg void OnLvnItemchangedLcObj(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnLvnItemchangedLcShape(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	DECLARE_MESSAGE_MAP()
public:
	CStatic		m_sttFrame;
	CListCtrl	m_lcObj;
	CListCtrl	m_lcShapeFrame;
	CImageList	m_imageList;
	CListCtrl	m_lcShapeInfo;
	CListCtrl	m_lcSelObjInfo;
	CSliderCtrl m_scZMax;
	afx_msg void OnFileExit();
	afx_msg void OnFileLoad();
};
